<?php
	@header('Content-type:text/html;charset=UTF-8');
	error_reporting(E_ALL|E_STRICT);
	date_default_timezone_set('Asia/Shanghai');
	define('ROOT_DIR', dirname(dirname(__FILE__)));
	define('WEB_ROOT', 'http://www.weibaitao.com/show');
	set_include_path('.'.PATH_SEPARATOR.'./library/'.PATH_SEPARATOR.'./application/models/'.PATH_SEPARATOR.get_include_path());
    require('Zend/Loader/Autoloader.php');
	Zend_Loader_Autoloader::getInstance()->registerNamespace('web');//Zend框架的名字空间
	Zend_Loader_Autoloader::getInstance()->registerNamespace('admin');//我自己的类的名字空间
	Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);//能够载入无名子空间的类，比如models目录下的类。

    
	Zend_Session::start();
	$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
	Zend_Registry::set('config',$config);
	
	//$db=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
	//$db->query('SET NAMES UTF8');
	//Zend_Db_Table::setDefaultAdapter($db);
	//Zend_Registry::set('db',$db);
	
	
	
	$smarty=new Custom_View_Smarty($config->smarty->toarray());
	Zend_Registry::set('smarty',$smarty);
	
	$auth=Zend_Auth::getInstance();
	$acl=new Custom_KenAcl();
    $frontController = Zend_Controller_Front::getInstance();
	$frontController->addModuleDirectory('./application/modules')
                ->registerPlugin(new Custom_Controller_Plugin_Smarty())
                ->setBaseUrl('')
                ->setParam('useDefaultControllerAlways', true)
                ->setParam('noViewRenderer', true)
                ->setParam('noErrorHandler', true)
                ->setParam('useDefaultControllerAlways', true)
            	->registerPlugin(new Custom_Controller_Plugin_KenAuth($auth, $acl));
	$frontController->throwExceptions(true); 
	$frontController->dispatch();